import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
import pandas as pd
from pathos.multiprocessing import Pool, cpu_count
import seaborn as sns
import scipy
import pathos
from subprocess import Popen, PIPE
import getpass
import emcee
from functools import partial

from tqdm.notebook import tqdm
from operator import add
from functools import reduce
from contextlib import closing

df_out = pd.read_csv('estimation/simulation_estimates/simulations_binaryevents_atmean.csv')


with open('figs/tableOB1_sim.txt', 'w') as f:
    f.write('Treatment Num Event:')
    f.write(str(df_out['treatment_num_event'].values[0]))
    f.write('\n')
    f.write('Control Num Event:')
    f.write(str(df_out['control_num_event'].values[0]))
    f.write('\n')


with open('figs/tableOB2_sim.txt', 'w') as f:
    f.write('Treatment Average Payment Per Event:')
    f.write(str(df_out['treatment_average_payment_per_event'].values[0]))
    f.write('\n')
    f.write('Control Average Payment Per Event:')
    f.write(str(df_out['control_average_payment_per_event'].values[0]))
    f.write('\n')


with open('figs/tableOB2_sim.txt', 'a') as f:
    f.write('Treatment Average Payment Per Event (<99p):')
    f.write(str(df_out['treatment_average_payment_per_event_p99'].values[0]))
    f.write('\n')
    f.write('Control Average Payment Per Event (<99p):')
    f.write(str(df_out['control_average_payment_per_event_p99'].values[0]))
    f.write('\n')
